package com.wrl.mmall.common.enums;

import lombok.Getter;

/**
 * 订单状态
 *
 * @author Wang Renlei
 * @Date 2020/5/7 0007
 */
@Getter
public enum OrderStatusEnum {
    CANCELED(0, "已取消"),
    NO_PAY(10, "未支付"),
    PAID(20, "已付款"),
    SHIPPED(40, "已发货"),
    ORDER_SUCCESS(50, "订单完成"),
    ORDER_CLOSE(60, "订单关闭");

    private int code;
    private String value;

    OrderStatusEnum(int code, String value) {
        this.code = code;
        this.value = value;
    }

    //静态方法。传过来code，返回汉字
    public static OrderStatusEnum codeOf(int code) {
        for (OrderStatusEnum ose : values()) {
            if (code == ose.getCode()) {
                return ose;
            }
        }
        throw new RuntimeException("没有找到对应的枚举");
    }
}
